<template>
  <div class="rights">
    <!-- 面包屑导航 -->
    <breadcrumb :breadcrumb="breadcrumb"></breadcrumb>
    <!-- 内容卡片区 -->
    <el-card class="box-card content">
      <!-- 列表 -->
      <el-table :data="rightsList" style="width: 100%" border>
        <el-table-column type="index" label="#" width="80"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column prop="address" label="权限等级" width="280">
          <template slot-scope="scope">
            <el-tag size="medium" type="success" v-if="scope.row.level==0">一级</el-tag>
            <el-tag size="medium" type="info" v-if="scope.row.level==1">二级</el-tag>
            <el-tag size="medium" type="warning" v-if="scope.row.level==2">三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
           
<script>
export default {
  name: "rights",
  data() {
    return {
      // 面包屑导航传值
      breadcrumb: ["权限管理", "权限列表"],
      // 权限列表
      rightsList: []
    };
  },
  // 生命周期函数
  created() {
    this.getRights();
  },
  methods: {
    // 初始化
    async getRights() {
      const { data: res } = await this.$http.get(`/rights/list`);
      if (res.meta.status == 200) {
        this.$message({
          message: res.meta.msg || "获取列表成功",
          type: "success"
        });
        this.rightsList = res.data;
      }
    }
  }
};
</script>
<style scoped lang='less'>
.rights {
  width: 100%;
  height: 100%;
  .content {
    margin-top: 10px;
    padding: 10px 20px;
    background-color: #fff;
    margin-top: 20px;
    border-radius: 8px;
  }
}
</style>